import { Dictionary } from "../Common/Dictionary";
/**ID生成器 */
export class IdGenerator {

    private static idList: Dictionary<number, number> = new Dictionary<number, number>();
    /**起始编号 */
    private static BEGINID: number = 100;
    /**
     * Get Id by type
     */
    public static getId(idType: number): number  {

        //100 101 102
        var res: number = 0;
        if (!this.idList.containsKey(idType))  {
            res = this.BEGINID;
            this.idList.set(idType, res);
        }
        else  {
            res = this.idList.get(idType);
            res++;
            this.idList.set(idType, res);
        }
        return res;
    }


    public static removeId(idType: number): void  {
        this.idList.remove(idType);
    }

    public static clearAll(): void  {
        this.idList = new Dictionary<number, number>();
    }
} 